package com.vctgo.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vctgo.common.log.annotation.Log;
import com.vctgo.common.log.enums.BusinessType;
import com.vctgo.common.security.annotation.RequiresPermissions;
import com.vctgo.system.domain.TProfession;
import com.vctgo.system.service.ITProfessionService;
import com.vctgo.common.core.web.controller.BaseController;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vctgo.common.core.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 * 行业Controller
 *
 * @author vctgo
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/profession")
public class TProfessionController extends BaseController
{
    @Autowired
    private ITProfessionService tProfessionService;

    /**
     * 查询行业列表
     */
    @RequiresPermissions("system:profession:list")
    @GetMapping("/list")
    public AjaxResult list(TProfession tProfession)
    {
        IPage<TProfession> list = tProfessionService.selectTProfessionPage(tProfession);
        return AjaxResult.success(list);
    }

    /**
     * 导出行业列表
     */
    @RequiresPermissions("system:profession:export")
    @Log(title = "行业", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TProfession tProfession)
    {
        List<TProfession> list = tProfessionService.selectTProfessionList(tProfession);
        ExcelUtil<TProfession> util = new ExcelUtil<TProfession>(TProfession.class);
        util.exportExcel(response, list, "行业数据");
    }

    /**
     * 获取行业详细信息
     */
    @RequiresPermissions("system:profession:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tProfessionService.selectTProfessionById(id));
    }

    /**
     * 新增行业
     */
    @RequiresPermissions("system:profession:add")
    @Log(title = "行业", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProfession tProfession)
    {
        return toAjax(tProfessionService.insertTProfession(tProfession));
    }

    /**
     * 修改行业
     */
    @RequiresPermissions("system:profession:edit")
    @Log(title = "行业", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProfession tProfession)
    {
        return toAjax(tProfessionService.updateTProfession(tProfession));
    }

    /**
     * 删除行业
     */
    @RequiresPermissions("system:profession:remove")
    @Log(title = "行业", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProfessionService.deleteTProfessionByIds(ids));
    }
}
